package com.lagou.servlet;

import com.lagou.bean.Student;
import com.lagou.service.StudentSerive;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "DelSudentServlet", value = "/DelSudentServlet")
public class DelSudentServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //1.获取请求中的信息
        String del = request.getParameter("del");
        //2.创建StudentService对象删除学生
        StudentSerive studentSerive = new StudentSerive();
        int i = studentSerive.delStudent(del);
        System.out.println(i);

        if (0!=1){
            response.sendRedirect("main.jsp");
        }else{
            RequestDispatcher requestDispatcher = request.getRequestDispatcher("main.jsp");
            requestDispatcher.forward(request,response);
        }

    }
}
